from django import forms

from App import models
from App.bootstrap import BootStrapModelForm


class AddOrderForm(BootStrapModelForm):
    # 员工电话
    phone = forms.CharField(
        min_length=11,
        max_length=11,
        label='员工电话',
        widget=forms.TextInput(attrs={
            'placeholder': '请输入员工电话号码',
        })
    )
    # 用户电话号码
    c_phone = forms.CharField(
        min_length=11,
        max_length=11,
        label='用户电话号码',
        widget=forms.TextInput(attrs={
            'placeholder': '请输入用户电话号码',
        })
    )
    marryTime = forms.CharField(
        label="婚宴时间",
        widget=forms.TextInput(attrs={
            'placeholder':'请输入婚宴时间'
        })
    )
    # 其他联系方式
    c_other = forms.CharField(
        min_length=11,
        max_length=11,
        label='其他联系方式',
        widget=forms.TextInput(attrs={
            'placeholder': '请输入用户电话号码',
        })
    )

    # 订单状态 已完成、未完成、已取消、已中止、已付款、未付款、已退款、需跟进、未核实
    status = forms.ChoiceField(
        choices=(
            ("未完成", "未完成"),
            ("未核实", "未核实"),
            ("已完成", "已完成"),
            ("已取消", "已取消"),
            ("已中止", "已中止"),
            ("已付款", "已付款"),
            ("未付款", "未付款"),
            ("已退款", "已退款"),
            ("需跟进", "需跟进"),
        ),
        label='订单状态'
    )

    class Meta:
        model = models.OrderManager
        exclude = ["create_time", "update_time"]  # 排除的字段
        widgets = {
            "customer": forms.TextInput(attrs={'placeholder': '请输入客户名称'}),
        }

        # 勿删
        #
        # def __init__(self, *args, **kwargs):
        #     self.request = kwargs.pop('request')
        #     user_id=self.request.session.get("userId")
        #     super(AddOrderForm,self).__init__(*args, **kwargs)
        #     self.fields['userId'].initial=user_id
